home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C - WorkDisk II.adf / line9.c < prev    next >
C/C++ Source or Header  |  1987-02-18  |  4KB  |  239 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3. #include "graphics/gfxmacros.h"
  4. #include "math.h"
  5.  
  6. struct IntuitionBase *IntuitionBase;
  7. struct Window *NoBorder;
  8. struct GfxBase *GfxBase;
  9. struct Screen *Scrn;
  10. struct IntuiMessage *mesg;
  11. struct RastPort *r;
  12.  
  13.  
  14. #define INTUITION_REV 29
  15. #define GRAPHICS_REV 29
  16.  
  17. main()
  18. {
  19.  ULONG flags,mclass;
  20.  SHORT x,y,w,h,d,c0,c1,einde,txt0ycrd,txt1ycrd,txt2ycrd,ix;
  21.  USHORT mode;
  22.  int len;
  23.  char *txt0,*txt1,*txt2;
  24.  double il,ih;
  25.  
  26. /* static UWORD patroon[]=
  27.  {
  28.   0x0AA0,
  29.   0xA00A,
  30.   0x0BB0,
  31.   0xB00B,
  32.   0xB00B,
  33.   0x0BB0,
  34.   0xA00A,
  35.   0x0AA0
  36.  }; */
  37.  
  38.  VOID OpenALL();
  39.  
  40.  OpenALL();
  41.  
  42.  /* ======Open een lores custom screen====== */
  43.  
  44.  y=0;
  45.  w=320;
  46.  h=200;
  47.  d=5; /* max 32 colors ! */
  48.  c0=0x00;
  49.  c1=0x01;
  50.  mode=NULL;
  51.  
  52.  Scrn=(struct Screen *)
  53.          make_screen(y,w,h,d,c0,c1,mode,NULL);
  54.  
  55.  /* ======open een borderless window ====== */
  56.  
  57.  x=y=0;
  58.  w=320;
  59.  h=200;
  60.  flags=ACTIVATE|NOCAREREFRESH|BORDERLESS|BACKDROP;
  61.  NoBorder=(struct Window *)
  62.              make_window(x,y,w,h,NULL,flags,Scrn);
  63.  
  64.  /* ======geen screentitel====== */
  65.  
  66.  ShowTitle(Scrn,0);
  67.  
  68.  /* ======definitie van RPort !====== */
  69.  
  70.  r=NoBorder->RPort;
  71.  
  72.  
  73.   for(x=1;x<16;x++)
  74.    { 
  75.    SetRGB4(ViewPortAddress(NoBorder),   x, x,(7-x)%16,15);
  76.    SetRGB4(ViewPortAddress(NoBorder),16+x,15,x,0);
  77.    };
  78.  
  79.   for(x=0;x<360;x++)
  80.    {
  81.       SetAPen(r,((SHORT)x)%32);
  82.       line(r,79,49  ,ih+=1,40.0);
  83.       line(r,239,149,ih+=1,40.0);
  84.       line(r,239,49 ,ih+=1,40.0);
  85.       line(r,79,149 ,ih+=1,40.0);
  86.  
  87.    };
  88.  
  89.  for(y=1;y<256;y++)
  90.   {
  91.   for(x=1;x<16;x++)
  92.    {
  93.    SetRGB4(ViewPortAddress(NoBorder),   x, x,(7-x)%16,15);
  94.    SetRGB4(ViewPortAddress(NoBorder),16+x,15,x,0); 
  95.    }
  96.   };
  97.  
  98.  
  99.  
  100.  /* ======einde in stijl !====== */
  101.  
  102. einde=0; /* init einde op 0 ! */
  103. while (einde != 1)
  104.  {
  105.   Wait(1<<NoBorder->UserPort->mp_SigBit);
  106.  
  107.   while((mesg=(struct IntuiMessage *)
  108.       GetMsg(NoBorder->UserPort))!=NULL)
  109.   {
  110.    ReplyMsg(mesg);
  111.    mclass=mesg->Class;
  112.   }
  113.  
  114.   if(mclass==MOUSEBUTTONS)
  115.    {
  116.      einde=1;
  117.      cleanwindow(r);
  118.      CloseWindow(NoBorder);
  119.      CloseScreen(Scrn);
  120.    }
  121.  }
  122.  
  123. } /********************************** einde van main **********************/
  124.  
  125. VOID OpenALL()
  126. {
  127.  /*==Intuition==*/
  128.  
  129.  IntuitionBase=(struct IntuitionBase *)
  130.             OpenLibrary("intuition.library",INTUITION_REV);
  131.  
  132.  if(IntuitionBase==NULL)
  133.     exit(FALSE);
  134.  
  135.  /*==Graphics Library==*/
  136.  
  137.  GfxBase=(struct GfxBase *)
  138.           OpenLibrary("graphics.library",GRAPHICS_REV);
  139.  
  140.  if(GfxBase==NULL)
  141.     exit(FALSE);
  142. }
  143.  
  144. make_window(x,y,w,h,name,flags,screen)
  145. SHORT x,y,w,h;
  146. UBYTE *name;
  147. ULONG flags;
  148. struct Screen *screen;
  149.  
  150. {
  151.  struct NewWindow NewWindow;
  152.  
  153.  NewWindow.LeftEdge = x;
  154.  NewWindow.TopEdge = y;
  155.  NewWindow.Width = w;
  156.  NewWindow.Height = h;
  157.  NewWindow.DetailPen = -1;
  158.  NewWindow.BlockPen = -1;
  159.  NewWindow.Title = name;
  160.  NewWindow.Flags = flags;
  161.  NewWindow.IDCMPFlags = MOUSEBUTTONS;
  162.  NewWindow.Type = CUSTOMSCREEN;
  163.  NewWindow.FirstGadget = NULL;
  164.  NewWindow.CheckMark = NULL;
  165.  NewWindow.Screen = screen;
  166.  NewWindow.BitMap = NULL;
  167.  NewWindow.MinWidth = 0;
  168.  NewWindow.MinHeight = 0;
  169.  NewWindow.MaxWidth = 0;
  170.  NewWindow.MaxHeight = 0;
  171.  
  172.  return(OpenWindow(&NewWindow));
  173.  
  174. }
  175.  
  176.  
  177. make_screen(y,w,h,d,color0,color1,mode,name)
  178. SHORT y,w,h,d;
  179. UBYTE color0,color1,*name;
  180. USHORT mode;
  181. {
  182.  struct NewScreen NewScreen;
  183.  
  184.  NewScreen.LeftEdge = 0;
  185.  NewScreen.TopEdge = y;
  186.  NewScreen.Width = w;
  187.  NewScreen.Height = h;
  188.  NewScreen.Depth = d;
  189.  NewScreen.DetailPen = color0;
  190.  NewScreen.BlockPen = color1;
  191.  NewScreen.ViewModes = mode;
  192.  NewScreen.Type = CUSTOMSCREEN;
  193.  NewScreen.Font = NULL;
  194.  NewScreen.DefaultTitle = name;
  195.  NewScreen.Gadgets = NULL;
  196.  NewScreen.CustomBitMap = NULL;
  197.  
  198.  return(OpenScreen(&NewScreen));
  199. }
  200.  
  201.  
  202. line(rast,x0,y0,hoek,l)
  203. struct RastPort *rast;
  204. SHORT x0,y0;
  205. double hoek,l;
  206. {
  207.  
  208.  double gnr,dx,dy;
  209.  gnr=3.141592/180.0;
  210.  dx=l*cos(hoek*gnr);
  211.  dy=l*sin(hoek*gnr);
  212.  
  213.  Move(rast,(SHORT)(x0-dx),(SHORT)(y0+dy));
  214.  Draw(rast,(SHORT)(x0+dx),(SHORT)(y0-dy));
  215.  
  216. }
  217.  
  218.  
  219.  
  220. cleanwindow(rast)
  221. struct RastPort *rast;
  222. {
  223.  SHORT i,x2,y2;
  224.  
  225.  SetAPen(rast,0); /* zwart */
  226.  SetBPen(rast,1); /* wit  */
  227.  
  228.  
  229.  for(i=0;i<200;i++)
  230.   {
  231.    Move(rast,0,0);Draw(rast,319,i);
  232.    Move(rast,319,0);Draw(rast,0,i);
  233.    Move(rast,0,199);Draw(rast,319,199-i);
  234.    Move(rast,319,199);Draw(rast,0,199-i);
  235.   }
  236. }
  237.  
  238.  
  239.